Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve types around template rendering #258

Merged
merged 9 commits into from
Aug 8, 2024

Conversation

noelleleigh
Copy link

Big improvements here are:

  • template.Template.render now returns SafeText instead of Any.
  • DjangoDivFormRenderer and Jinja2DivFormRenderer in forms.renderers.
  • A template.backends.base._BaseTemplate protocol class that imitates the abstract BaseTemplate class from DEP 182. This is needed because there is no real parent class from which each template backend inherits from, they implement their own Template classes from scratch. So, BaseEngine needed a return type for its abstract methods, which is what _BaseTemplate provides.

Other changes include reducing repetition, adding more specific Template types for the different backends, using more generic Mapping type instead of dict for template contexts.

Copy link
Owner

@sbdchd sbdchd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@kodiakhq kodiakhq bot merged commit b36b99f into sbdchd:main Aug 8, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants